import java.util.Scanner;

public class work2 {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int q=scanner.nextInt();
        int []arr=new int[n+1];
        for (int i = 1; i <=n ; i++) {
            int temp=scanner.nextInt();
            arr[i]=temp;
        }
        for (int i = 0; i <q ; i++) {
            int l=scanner.nextInt();
            int r=scanner.nextInt();
            long temp=0;
            for (int j = l; j <=r; j++) {
                temp+=arr[j];
            }
            System.out.println(temp);
        }
    }
}
